﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PMP
{
    public abstract class ID3V2: TagReader
    {
        protected Dictionary<string, string> Frames_ID3V2 { get; set; }

        public ID3V2(string path)
            : base(path)
        {
            Frames_ID3V2 = new Dictionary<string, string>();
            Frames_ID3V2.Add("Title", "TIT2");
            Frames_ID3V2.Add("Album", "TALB");
            Frames_ID3V2.Add("Artist", "TOPE");
            Frames_ID3V2.Add("Track", "TRCK");
        }

        protected string GetFrameDesc(string name, Dictionary<string, string> overrides)
        {
            return (overrides[name] != null
                ? overrides[name]
                : Frames_ID3V2[name]);
        }

        public override string Path
        {
            get
            {
                return base.Path;
            }
            protected set
            {
                base.Path = value;
            }
        }

        public override string Title
        {
            get
            {
                return base.Title;
            }
            protected set
            {
                if (!string.IsNullOrWhiteSpace(value))
                {
                    base.Title = value;
                }
            }
        }

        public override string Album
        {
            get
            {
                return base.Album;
            }
            protected set
            {
                if (!string.IsNullOrWhiteSpace(value))
                {
                    base.Album = value;
                }
            }
        }

        public override string Artist
        {
            get
            {
                return base.Artist;
            }
            protected set
            {
                if (!string.IsNullOrWhiteSpace(value))
                {
                    base.Artist = value;
                }
            }
        }

        public override int Track
        {
            get
            {
                return base.Track;
            }
            protected set
            {
                base.Track = value;
            }
        }

        public abstract override bool IsThisTagType { get; }
    }
}
